/*
* Circle.cpp
*
*  Created on: Jan 20, 2011
*      Author: Team MRF
*/

#include "Circle.h"


namespace gsp280Project2
{
	//Overloaded Constructor
	// Blodgett cmt: float
	Circle::Circle ( const float &Radius )
	{
		// Blodgett cmt: Variables should start with lowercase

		radius = Radius; // this.radius  = Radius

		//set collision collisionBox
		collisionBox.setLocation(Location);
		collisionBox.setHeight(Radius);
		collisionBox.setWidth(Radius);
	}

	//set the radius of the circle
	void Circle::setRadius ( const float &Radius )
	{
		radius = Radius;

		//update collision collisionBox
		collisionBox.setHeight( Radius );
		collisionBox.setWidth( Radius );
	}

	//return the radius of the circle
	const float Circle::getRadius ( ) const
	{
		return radius;
	}

	//return collsionBox location
	const Vector2 Circle::getCollisionBox_Location() const
	{
		return ( collisionBox.getLocation() );
	}

	//return collsionBox location_X
	const float Circle::getCollisionBox_Location_X() const
	{
		return ( collisionBox.getLocation_X() );
	}

	//return collsionBox location_Y
	const float Circle::getCollisionBox_Location_Y() const
	{
		return ( collisionBox.getLocation_Y() );
	}

	//return collsionBox Height

	// Blodgett cmt: change int data type
	const float Circle::getCollisionBox_Height() const
	{
		return ( collisionBox.getHeight() );
	}

	//return collsionBox Width
	const float Circle::getCollisionBox_Width ( ) const
	{
		return ( collisionBox.getWidth() );
	}

	//calculate area of circle
	const float Circle::calcArea ( ) const
	{
		// use the GRAVITY constant instead
		return (double(3.14159 * radius * radius));
	}

	//set the location of the circle given a vector
	void Circle::setLocation(const Vector2 &vect)
	{
		Location = vect;
		collisionBox.setLocation(vect); //update collision location
	}

	//set the location of the circle given x,y
	void Circle::setLocation(const float &x, const float &y)
	{
		Location.setVector2(x,y);
		collisionBox.setLocation(x,y); //update collision location
	}
	
	//set the location_X of the circle
	void Circle::setLocation_X(const float &x)
	{
		Location.setX(x);
		//update collision location_X
		collisionBox.setLocation_X(x);
	}
	
	//set the location_Y of the circle
	void Circle::setLocation_Y(const float &y)
	{
		Location.setY(y);
		collisionBox.setLocation_Y(y); //update collision location_Y
	}

	//get the location of the circle in Vector2
	const Vector2 Circle::getLocation() const
	{
		return Location; 
	}

	//get the location_X of the circle
	const float Circle::getLocation_X() const
	{
		return Location.getX();
	}

	//get the location_Y of the circle
	const float Circle::getLocation_Y() const
	{
		return Location.getY();
	}

	//Detect IF 'this'collides with input obj
	const bool Circle::intersects( const Circle &target )
	{
		bool hasCollided = false;

		if (
			(
			//(coll.getLocation_X() >= (this->getLocation_X() - coll.getCollisionBox_Width())) && (coll.getLocation_X() <= (this->getLocation_X() + this->getCollisionBox_Width()) )
			(this->getLocation_X() >= (target.getLocation_X() - this->getCollisionBox_Width())) && (this->getLocation_X() <= (target.getLocation_X() + this->getCollisionBox_Width()) )
			) &&
			(
			(this->getLocation_Y() >= (target.getLocation_Y() - this->getCollisionBox_Height())) && (this->getLocation_Y() <= (target.getLocation_Y() + target.getCollisionBox_Height()) )
			)
			)
		{
			hasCollided = true;
			//cout << "Collision = true!\n\n";
		}
		else
		{
			hasCollided = false;
			//cout << "Collision = false!\n\n";
		}

		return ( hasCollided );
	}

	//Round float to 2 decimal places
	const float Circle::float_RoundOff2 ( float value )
	{
		return ( collisionBox.float_RoundOff2(value) );
	}

	//Get Bottom-Left Vertex of Obj
	const Vector2 Circle::getVertex_BL ( ) const
	{
		return ( collisionBox.getVertex_BL() );
	}

	//Set Bottom-Left Vertex of Obj
	void Circle::setVertex_BL ( const float &x, const float &y )
	{
		collisionBox.setVertex_BL( x, y );
	}

	//Get Bottom-Right Vertex of Obj
	const Vector2 Circle::getVertex_BR ( ) const
	{
		return ( collisionBox.getVertex_BR() );
	}

	//Set Bottom-Right Vertex of Obj
	void Circle::setVertex_BR ( const float &x, const float &y )
	{
		collisionBox.setVertex_BR( x, y );
	}

	//Get Top-Left Vertex of Obj
	const Vector2 Circle::getVertex_TL ( ) const
	{
		return ( collisionBox.getVertex_TL() );
	}

	//Set Top-Left Vertex of Obj
	void Circle::setVertex_TL ( const float &x, const float &y )
	{
		collisionBox.setVertex_TL( x, y );
	}

	//Get Top-Right Vertex of Obj
	const Vector2 Circle::getVertex_TR ( ) const
	{
		return ( collisionBox.getVertex_TR() );
	}

	//Set Top-Right Vertex of Obj
	void Circle::setVertex_TR ( const float &x, const float &y )
	{
		collisionBox.setVertex_TR( x, y );
	}

}//namespace
